package com.yang.wfcuser.controller;

import com.yang.wfcuser.pojo.vo.ProductInfoVO;
import com.yang.wfcuser.pojo.vo.UserListVO;
import com.yang.wfcuser.security.LoginPrincipal;
import com.yang.wfcuser.serive.ProductService;
import com.yang.wfcuser.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@RestController
@RequestMapping("/product")
@Api(tags = "商品管理模块")
@Slf4j
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("")
    @ApiOperation("商品列表查询")
    public JsonResult<List<ProductInfoVO>> list() {
        List<ProductInfoVO> list = productService.list();
        return JsonResult.ok(list);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据商品id查询")
    public JsonResult<ProductInfoVO> getProductInfoById(@PathVariable("id") Long id){
        ProductInfoVO productInfoVOById = productService.getProductInfoVOById(id);
        System.out.println(productInfoVOById);
        return JsonResult.ok(productInfoVOById);
    }

}
